﻿#pragma once
#include <QWebEngineView>
#include <QWebChannel>

class WebEngineView : public QWebEngineView
{
	Q_OBJECT
public:
	explicit WebEngineView(QWidget* parent = nullptr);
	~WebEngineView();
	void openDevTool();
	static QWebEngineView* instance();
protected:
	virtual QWebEngineView* createWindow(QWebEnginePage::WebWindowType type) override;
public slots:
	//定义一个槽函数，接收 web 端发的消息，js调用Qt的函数
	void recieveJsMessage(const QString& jsMsg);
private:
	QUrl m_url;
	static WebEngineView* m_instance;
	QWebChannel* m_pWebChannel = nullptr;
	QWebEngineView* m_devTool = nullptr;
};

